package org.entities;


import org.newdawn.slick.Graphics;
import org.newdawn.slick.SlickException;
import org.newdawn.slick.Animation;
import org.newdawn.slick.SpriteSheet;


public class Switch extends LevelObject {
    
    public Animation fallback;      
	private static int size[]={0,0,16,0,16,32,0,32};

    
	public Switch(float x, float y, String type) throws SlickException {
	    		
	    // building are polygon around the sprite.
		super(x,y,				
		x+size[0], y+size[1], 
		x+size[2], y+size[3],
		x+size[4], y+size[5],
		x+size[6], y+size[7],
        type);
		
        SpriteSheet sheet = new SpriteSheet("data/anim/elevSwitch.png",16,32);
        fallback = new Animation();
        for (int frame=0;frame<3;frame++) {
           fallback.addFrame(sheet.getSprite(frame,0), 700);
        }
        fallback.setAutoUpdate(false);
	}	
	
	public void update(int delta) throws SlickException {

	    fallback.update(delta);
	}
	
    public boolean isCollisionWith(LevelObject other) {        
     
        return poly.intersects(other.poly);
    }

    public boolean collidedWith(LevelObject entity) {
        return true;
    }
	
	
	public void draw(Graphics g) {
		g.drawAnimation(fallback, x, y);
        if (debugMode)
            g.draw(poly);
	}
}